GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Store.js ➔ ???   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 6
Bugs 0 Features 0
Metric Value
c 6
b 0
f 0
nc 1
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
cc 1
crap 1
nop 1
1
import debugRenderer from 'debug';
2 1
let debug = debugRenderer('icls:store:inmemory');
3
4
export default class InMemoryStore {
5
6
    constructor (initialStore = {}) {
7 19
        this._store = initialStore;
8
    }
9
10
    _recurse (key, value) {
11 58
        if (key === undefined) {
12 1
            return this._store;
13
        }
14
15 57
        let writeMode = value !== undefined;
16
17 57
        let currentLevel = this._store;
18 57
        let levels = key.split('.');
19
20 57
        for (let i = 0, l = levels.length; i < l; i++) {
21 91
            if (!writeMode && currentLevel[levels[i]] === undefined) {
22 1
                return null;
23
            }
24
25 90
            if (!writeMode) {
26 6
                currentLevel = currentLevel[levels[i]];
27 6
                continue;
28
            }
29
30 84
            if (currentLevel[levels[i]] === undefined) {
31 52
                currentLevel[levels[i]] = {};
32
            }
33
34 84
            if (i + 1 === l) {
35 53
                currentLevel[levels[i]] = value;
36
            }
37
38 84
            currentLevel = currentLevel[levels[i]];
39
        }
40
41 56
        return currentLevel;
42
    }
43
44
    get (key, defaultValue = null) {
45 5
        debug('Get key %s with default value %s', key, defaultValue);
46 5
        return this._recurse(key) || defaultValue;
47
    }
48
49
    set (key, value) {
50 53
        debug('Set key %s with value %s', key, value);
51 53
        this._recurse(key, value);
52 53
        return this;
53
    }
54
55
    reset () {
56 1
        debug('Reset store');
57 1
        this._store = {};
58
    }
59
60
    toJS () {
61 7
        return this._store;
62
    }
63
64
}
65